package com.wangqingbo.myspringbootproject.entity;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.ImportResource;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 学生的对象，从yml配置文件中读取数据
 * @Component:将类注册成一个bean
 *@ConfigurationProperties(prefix = "student"):从配置文件中读取数据
 * prefix：配置文件中的前缀，在配置文件的最顶层
 * @ImportResource(""):引入xml的配置文件
 */
@Component
@ConfigurationProperties(prefix = "student")
@ImportResource("classpath:beans.xml")
public class StudentInfo {

    // 姓名，这个属性名称和配置文件中student为前缀的key值对应即可
    private String username;
    // 年龄
    //@Max()
    private int age;
    // 名称1，值中带有双引号,有特殊字符的时候，要用双引号
    private String username1;
    // 名称2，值中带有单引号
    private String username2;

    // 去过的城市
    private List<String> cityes;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getUsername1() {
        return username1;
    }

    public void setUsername1(String username1) {
        this.username1 = username1;
    }

    public String getUsername2() {
        return username2;
    }

    public void setUsername2(String username2) {
        this.username2 = username2;
    }

    public List<String> getCityes() {
        return cityes;
    }

    public void setCityes(List<String> cityes) {
        this.cityes = cityes;
    }
}
